package tw.com.book;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;

public class IssueView extends View {

	private int width = 0;
	private int height = 0;
	private Paint paint = null;
	private Context content = null;
	private int unit = 50;

	private String title="";
	private String txt="";

	public IssueView(Context context) {
		super(context);
		this.content = context;
		// TODO Auto-generated constructor stub
		paint = new Paint();
	}

	public IssueView(Context context, AttributeSet attrs) {
		super(context, attrs);
		this.content = context;

		paint = new Paint();
	}

	@Override
	protected void onDraw(Canvas canvas) {

		canvas.drawColor(Color.LTGRAY);

		this.paint.setColor(Color.GRAY);
		paint.setTextSize(45);
		
		Paint titlePaint=new Paint();
		titlePaint.setColor(Color.GRAY);
		titlePaint.setTextSize(80);
		
//		canvas.drawText(this.title, x, y, titlePaint);

		for (int i = 0; i < height; i++) {
			canvas.drawLine(0, i * unit, width, (i + 1) * unit, paint);

		}

	}

	@Override
	protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {

		this.width = MeasureSpec.getSize(widthMeasureSpec);
		this.height = MeasureSpec.getSize(heightMeasureSpec);

		this.setMeasuredDimension(width, height);

		// TODO Auto-generated method stub
		super.onMeasure(widthMeasureSpec, heightMeasureSpec);
	}

	@Override
	public boolean onTouchEvent(MotionEvent event) {

		this.invalidate();

		return super.onTouchEvent(event);

	}

	public void setText(String title, String content) {

		this.title = title;
		this.txt = content;
		this.invalidate();
	}

}
